﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ItCool.Web.Models.Article>" %>
 <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% var cb = this.ViewContext.Controller as ItCool.Web.Controllers.ControllerBase;  %>
    <%  Html.EnableClientValidation(); %>
    
    <div id="content">
        <%Html.RenderPartial("usercenter/menu");%>
        <%: Html.ValidationSummary(true)%>
        <div class="userMain">
            <h2 class="title">
                修改信息
            </h2>
            <div class="u_box">
                <% using (Html.BeginForm("Edit", "article",new{id=ViewContext.RouteData.Values["id"]}, FormMethod.Post,new { enctype = "multipart/form-data" }))
                   {%>
                <table class="userInfo">
                    <tr>
                        <td class="text_right">
                            所选类别：
                        </td>
                        <td>
                            <%=Model.Node.Name%>
                        </td>
                    </tr>
                    <tr>
                        <td class="text_right">
                            地区：
                        </td>
                        <td>
                            <%=this.Select("AreaId").Options(ViewData["area"] as IList<SelectListItem>) %>
                            <%: Html.ValidationMessageFor(model => model.AreaId)%>
                        </td>
                    </tr>
                    <tr>
                        <td class="text_right">
                            <%: Html.LabelFor(model => model.Title)%>：
                        </td>
                        <td>
                            <%: Html.TextBoxFor(model => model.Title, new { @class = "txt", style = "width:450px;" })%>
                            <%: Html.ValidationMessageFor(model => model.Title)%>
                        </td>
                    </tr>
                    <%=Html.Partial("DynamicArticle", this.Model)%>
                    <tr>
                        <td class="text_right">
                            <%: Html.LabelFor(model => model.ArticleDeadLine)%>：
                        </td>
                        <td>
                            <%: Html.DropDownListFor(model => model.ArticleDeadLine, ViewData["dicts"] as IList<SelectListItem>)%>
                            <%: Html.ValidationMessageFor(model => model.ArticleDeadLine)%>
                        </td>
                    </tr>
                    <tr>
                        <td class="text_right">
                            <%: Html.LabelFor(model => model.Content)%>：
                        </td>
                        <td>
                            <%: Html.EditorFor(model => model.Content)%>
                            <%: Html.ValidationMessageFor(model => model.Content)%>
                        </td>
                        <tr>
                            <td class="text_right">
                                <%: Html.LabelFor(model => model.Msn)%>：
                            </td>
                            <td>
                                <%: Html.EditorFor(model => model.Msn)%>
                                <%: Html.ValidationMessageFor(model => model.Msn)%>
                            </td>
                        </tr>
                        <tr>
                            <td class="text_right">
                                <%: Html.LabelFor(model => model.QQ)%>：
                            </td>
                            <td>
                                <%: Html.EditorFor(model => model.QQ)%>
                                <%: Html.ValidationMessageFor(model => model.QQ)%>
                            </td>
                        </tr>
                        <tr>
                            <td class="text_right">
                                <%: Html.LabelFor(model => model.Tel)%>：
                            </td>
                            <td>
                                <%: Html.EditorFor(model => model.Tel)%>
                                <%: Html.ValidationMessageFor(model => model.Tel)%>
                            </td>
                        </tr>
                        <tr>
                            <td class="text_right">
                                <%: Html.LabelFor(model => model.Address)%>：
                            </td>
                            <td>
                                <%: Html.EditorFor(model => model.Address)%>
                                <%: Html.ValidationMessageFor(model => model.Address)%>
                            </td>
                        </tr>
                        <tr>
                            <td class="text_right">
                                <%: Html.LabelFor(model => model.LinkMan)%>：
                            </td>
                            <td>
                                <%: Html.EditorFor(model => model.LinkMan)%>
                                <%: Html.ValidationMessageFor(model => model.LinkMan)%>
                            </td>
                        </tr>
                        <% if (Page.User.Identity.IsAuthenticated)
                           { %>
                        <tr>
                            <td class="text_right">
                                <%: Html.LabelFor(model => model.ThumbSrc)%>：
                            </td>
                            <td>
                                  <img src='<%=Model.FullThumbSrc %>' />
                                <br /> <input type="file" name="ThumbSrc" /><%: Html.ValidationMessageFor(model => model.ThumbSrc)%>
                             
                                 
                            </td>
                        </tr>
                        <%}
                           else
                           { %>
                        <tr>
                            <td class="text_right">
                                <%: Html.LabelFor(model => model.EditByPassword)%>：
                            </td>
                            <td>
                                <%: Html.EditorFor(model => model.EditByPassword)%>
                                <%: Html.ValidationMessageFor(model => model.EditByPassword)%>
                            </td>
                        </tr>
                        <tr id="spanp" style="display: none;">
                            <td class="text_right">
                                <%: Html.LabelFor(model => model.ArticlePassword)%>：
                            </td>
                            <td>
                                <%: Html.EditorFor(model => model.ArticlePassword)%>
                                <%: Html.ValidationMessageFor(model => model.ArticlePassword)%>
                            </td>
                        </tr>
                        <%} %>
                        <tr>
                            <td class="text_right">
                            </td>
                            <td>
                                <input type="button" onclick="delR();" class="btn_login" value="返回列表" />
                                <input type="submit" value="保存信息" class="btn_login" />
                            </td>
                        </tr>
                </table>
                 <h2 class="title">
                更多图片 <input type="button" id="btnMore" onclick="getMorePic();" value="上传更多图片" class="btn_login" />
                </h2>
                <ul>
                <% foreach (var item in Model.ArticlePic) 
                { %>
                   <li id="li<%=item.Id %>">
                     <%=Html.ActionImageLink(item.FullThumbSrc, "more", "image", new { id = item.Id }, new { target = "_blank" })%>
                     <br /><a href="#this" onclick="deletePic(<%=item.Id %>);">删除</a>
                   </li>

                <%} %>
                </ul>
                <%=Html.Hidden("NodeID", Request.Params["Id"])%>
                <% } %>
            </div>
        </div>
    </div>
 
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphMeta" runat="server">
    <link type="text/css" rel="stylesheet" href="/css/userCenter.css" />
    <script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="/js/MicrosoftAjax.js"></script>
    <script type="text/javascript" src="/js/MicrosoftMvcValidation.js"></script>
    <script type="text/javascript" src="/js/MvcFoolproofValidation.min.js"></script>
    <script type="text/javascript">
        $(function (jQuery) {
            $('#EditByPassword').click(function () {
                if ($(this).attr("checked")) {
                    $('#spanp').show();
                }
                else {
                    $('#spanp').hide();
                }
            });

            var b = '<%=Model.EditByPassword %>';
            if (b == 'True') {
                $('#spanp').show();
            }
        });

        function delR() {
            location.href = '/usercenter/myArticle';
        }

        function deletePic(index) {
            if (window.confirm('你确认删除该图片？')) {
                $.get('/ArticlePic/delete/' + index, function (result) {
                    if (result == 1) {
                        $('#li' + index).hide();
                        alert('删除成功。');
                    }
                    else {
                        alert('网络原因，删除不成功。');
                    }
                });
            }
        }

        function getMorePic() {
            location.href = '/usercenter/swfupload?articleid=<%=ViewContext.RouteData.Values["id"] %>';
         }
    
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="cphFooter" runat="server">

</asp:Content>
